package cn.pugle.oj.leetcode;

import cn.pugle.oj.catalog.Greedy;

/**
 * https://leetcode.com/problems/is-subsequence/
 * <p>
 * 本身贪心不难想, 大神代码真简洁
 * 另外题后的思考题, 大神的解法也tql
 * https://www.bilibili.com/video/BV1aW411m79s?from=search&seid=15737798155215496918
 *
 * @author tzp
 * @since 2020/10/17
 */
public class LC392 implements Greedy {
    public boolean isSubsequence(String s, String t) {
        int k = 0;
        for (int i = 0; i < t.length() && k < s.length(); i++) {
            if (t.charAt(i) == s.charAt(k)) k++;
        }
        return k == s.length();
    }

    public static void main(String[] args) {
        System.out.println(new LC392().isSubsequence("abs", "fsfaffabfsbcfa"));
    }
}
